﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Product.Application;
using Product.Common.Command;

namespace ProductWebApi.Controllers
{
    [Route("api/product/v1/[controller]")]
    [ApiController]
    public class SpuController : ControllerBase
    {
        private readonly ISpuAppService _spuAppService;

        public SpuController(ISpuAppService spuAppService)
        {
            _spuAppService = spuAppService;
        }

        [HttpPost]
        public async Task AddSpu(AddSpuCommand cmd)
        {         
            var addSpu = new AddSpuCommand()
            {
                SpuName = "测试SPU名称",
                BrandId = "161616161",
                CategoryId = "53698696",
                PicUrl = "测试Url",
                SpecificationList = new List<SpecificationCommand>()
                 {
                    new SpecificationCommand(){SpecificationName="颜色",SpecificationValue="白色",Sort=3 },
                    new SpecificationCommand(){SpecificationName="颜色",SpecificationValue="蓝色",Sort=3 },
                 },
                SkuList = new List<SkuCommand>()
                {
                   new SkuCommand(){PicUrl="测试Url",Price=8888,Specification="['白色']",UnitId="2636363" },
                   new SkuCommand(){PicUrl="测试Url",Price=9999,Specification="['蓝色']",UnitId="2636363" }
                }
            };

           await _spuAppService.AddSpu(addSpu);
        }
    }
}
